<{extend name="base" /}>
<{block name="body"}>
<style>
.layui-form-item .layui-form-checkbox{
    width: 82px;
}
.layui-form-checkbox span{
    width: 30px;
}
.layui-form-mid{
    margin-left: 110px;
}
.layui-form-item  .layui-form-checkbox{
    width: 106px;
}

.layui-form-item   .layui-form-checkbox span{
    width: 52px;
}
</style>
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class="layui-this">配置</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form class="layui-form form-container" action="<{:url('admin/shb/save')}>" method="post">
                    <input type="hidden" name="id" value="<{$id|default=''}>">
                    <div class="layui-form-item">
                        <label class="layui-form-label">医院名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="yymc" value="<{$yymc|default=''}>"   lay-verify="required" placeholder="请输入医院名称" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">医院电话</label>
                        <div class="layui-input-block">
                            <input type="text" name="yy_tel" value="<{$yy_tel|default=''}>"   lay-verify="required" placeholder="请输入医院电话" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">医院性质</label>
                        <div class="layui-input-block">
                            <textarea type="text" name="yyxz" value="<{$yyxz|default=''}>"  lay-verify="required"   class="layui-textarea"><{$yyxz|default=''}></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">医院简介</label>
                        <div class="layui-input-block">
                            <textarea type="text" name="yyjj" value="<{$yyjj|default=''}>"  lay-verify="required"   class="layui-textarea"><{$yyjj|default=''}></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">医院特色</label>
                        <div class="layui-input-block">
                            <textarea type="text" name="yyts" value="<{$yyts|default=''}>"  lay-verify="required"   class="layui-textarea"><{$yyts|default=''}></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">引导页大图</label>
                        <div class="layui-input-block">
                            <input type="text" name="yy_pic" value="<{$yy_pic|default=''}>" id="yy_pic"  class="layui-input layui-input-inline">
                            <input type="file" name="file"  data-type='yy_pic' class="layui-upload-file">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">环境图</label>
                        <div class="layui-input-block">
                            <input type="text" name="yyhjtp"  value="<{$yyhjtp|default=''}>" id="banner" lay-verify="required"  class="layui-input layui-input-inline" >
                            <input type="file" name="file"  data-type='banner' class="layui-upload-file">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">客服软件</label>
                        <div class="layui-input-block">
                            <input type="radio" name="swt_type" value="swt" title="商务通"  checked>
                            <input type="radio" name="swt_type" value="kst" title="快商通" disabled >
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">客服软件ID</label>
                        <div class="layui-input-block">
                            <input type="text" name="swt_id" value="<{$swt_id|default=''}>"   lay-verify="required" placeholder="例如：PUT12920167" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="group-item" >
                        <div class="layui-form-item" >
                            <label class="layui-form-label">医生头像</label>
                            <div class="layui-input-block">
                                <input type="text" name="doctor_pic" value="<{$doctor_pic|default=''}>" id="doctor_pic" class="layui-input layui-input-inline">
                                <input type="file" name="file"  data-type='doctor_pic' class="layui-upload-file">
                            </div>
                        </div>
                    </div>
                    <div class="group-item" >
                        <div class="layui-form-item" >
                            <label class="layui-form-label">客户头像</label>
                            <div class="layui-input-block">
                                <input type="text" name="kehu_pic" value="<{$kehu_pic|default=''}>" id="kehu_pic" class="layui-input layui-input-inline">
                                <input type="file" name="file"  data-type='kehu_pic' class="layui-upload-file">
                            </div>
                        </div>
                    </div>


                    <div class="layui-form-item">
                        <label class="layui-form-label">默认关键词</label>
                        <div class="layui-input-block">
                            <input type="text" name="default_keyword" value="<{$default_keyword|default=''}>"   lay-verify="required"  autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">是否立即转到商务通</label>
                        <div class="layui-input-block">
                            <input type="radio" name="is_jump" value="1" title="是"  <{php}>if($is_jump==1 )echo "checked"; <{/php}> >
                            <input type="radio" name="is_jump" value="0" title="否" <{php}>if($is_jump==0 )echo "checked"; <{/php}> >
                        </div>
                      </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">直接访问时不开启</label>
                        <div class="layui-input-block">
                            <input type="radio" name="jj_switch" value="1" title="是"  <{php}>if($jj_switch==1 )echo "checked"; <{/php}> >
                            <input type="radio" name="jj_switch" value="0" title="否" <{php}>if($jj_switch==0 )echo "checked"; <{/php}> >
                        </div>
                      </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">对话(使用 [keyword] 嵌入关键词)</label>
                        <div class="layui-input-block" id="dialog">
                            <{php}>
                            $first_dialog = "在的!您是要咨询[keyword]相关的问题么?";
                            if(is_array($duihua_arr)){
                                if(!isset($duihua_arr[0])){
                                    $first_dialog = "";
                                }else{
                                    $first_dialog = $duihua_arr[0];
                                }
                            }
                            <{/php}>
                            <input type="text" name="duihua_arr[]" style="width:560px" lay-verify="required" value="<{$first_dialog}>" class="layui-input layui-input-inline">
                            <button type="button" onclick="addBottomItem()" class="layui-btn">添加一句对话</button>
                            <{php}>
                            if(is_array($duihua_arr)){
                           foreach($duihua_arr as $key=>$val){
                                if($key == 0) continue;
                                $k = $key+1;
                                echo '<div id="add'.$k.'" style="margin-top: 4px;">
                                <input type="text" name="duihua_arr[]" style="width:560px;" lay-verify="required" value="'.$val.'"  class="layui-input  layui-input-inline">
                                <button type="button" onclick="del(\'add'.$k.'\')" class="layui-btn layui-btn-danger">删除</button>
                            </div>';
                            }
                            }
                            <{/php}>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">对话间隔时间(秒)</label>
                        <div class="layui-input-block">
                            <input type="text" name="dialog_time" value="<{$dialog_time|default='3'}>"   lay-verify="required"  autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">开启时间段</label>
                        <{php}>
                        if(!$times){
                            $times = [];
                        }
                        if(!$areas){
                            $areas = [];
                        }
                        <{/php}>
                        <div class="layui-input-block times">
                            <{php}>
                            for($i=0;$i<24;$i++){
                                $j = $i+1;
                                $scope_time = "{$i}-{$j}点";
                                $checked = in_array($i,$times)?"checked":"";
                                echo "<input type=\"checkbox\" name=\"times[]\" value=\"{$i}\" title=\"{$scope_time}\" {$checked} />";
                            }
                            <{/php}>
                        </div>
                        <div class="layui-form-mid layui-word-aux">
                            0点表示 0点-1点范围 1点表示 1点到2点范围 以此类推
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">IP黑名单</label>
                        <div class="layui-input-block">
                            <textarea type="text" name="ips" value="<{$ips|default=''}>" placeholder="每行一个,最多30个"
                                      class="layui-textarea"><{$ips|default=''}></textarea>
                        </div>
                    </div>
                    <!-- <div class="layui-form-item">
                        <label class="layui-form-label">开启地域</label>
                        <div class="layui-input-block">
                             <input type="checkbox" name="areas[]" value="北京"  title="北京" <{if condition="in_array('北京',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="安徽"  title="安徽" <{if condition="in_array('安徽',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="重庆"  title="重庆" <{if condition="in_array('重庆',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="福建"  title="福建" <{if condition="in_array('福建',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="甘肃"  title="甘肃" <{if condition="in_array('甘肃',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="广东"  title="广东" <{if condition="in_array('广东',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="广西"  title="广西" <{if condition="in_array('广西',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="贵州"  title="贵州" <{if condition="in_array('贵州',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="海南"  title="海南" <{if condition="in_array('海南',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="河北"  title="河北" <{if condition="in_array('河北',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="黑龙江"  title="黑龙江" <{if condition="in_array('黑龙江',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="河南"  title="河南" <{if condition="in_array('河南',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="湖北"  title="湖北" <{if condition="in_array('湖北',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="湖南"  title="湖南" <{if condition="in_array('湖南',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="江苏"  title="江苏" <{if condition="in_array('江苏',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="江西"  title="江西" <{if condition="in_array('江西',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="吉林"  title="吉林" <{if condition="in_array('吉林',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="辽宁"  title="辽宁" <{if condition="in_array('辽宁',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="内蒙古"  title="内蒙古" <{if condition="in_array('内蒙古',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="宁夏"  title="宁夏" <{if condition="in_array('宁夏',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="青海"  title="青海" <{if condition="in_array('青海',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="山东"  title="山东" <{if condition="in_array('山东',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="上海"  title="上海" <{if condition="in_array('上海',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="山西"  title="山西" <{if condition="in_array('山西',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="陕西"  title="陕西" <{if condition="in_array('陕西',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="四川"  title="四川" <{if condition="in_array('四川',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="天津"  title="天津" <{if condition="in_array('天津',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="新疆"  title="新疆" <{if condition="in_array('新疆',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="西藏"  title="西藏" <{if condition="in_array('西藏',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="云南"  title="云南" <{if condition="in_array('云南',$areas)" }>checked<{/if}> />
                             <input type="checkbox" name="areas[]" value="浙江"  title="浙江" <{if condition="in_array('浙江',$areas)" }>checked<{/if}> />
                        </div>
                        <div class="layui-form-mid layui-word-aux">
                            请根据需求选定地域，防止被查封
                        </div>
                    </div> -->
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="*">提交</button>
                            <a href="/page?sn=<{$sn}>" target="_blank" class="layui-btn layui-btn-primary">预览</a>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<{/block}>
<{block name="script" }>
<script type="text/javascript">
    layui.upload({
        url: "/api/upload/upload",
        type: 'image',
        ext: 'jpg|png|gif|bmp',
        success: function (data,input) {
            console.log(input);
            if (data.error === 0) {
                var type = $(input).attr('data-type');
                $("#"+type).val(data.url);
            } else {
                layer.msg(data.message);
            }
        }
    });

    function del(id) {
        $("#"+id).remove();
    }
    function addBottomItem(){

        var i = $("#dialog div").length;
        var suggest = [
            '在的!',
            '请说,有什么问题?今年多大年龄了?',
            '你好!',
            '或者留个微信,我朋友圈有相关信息'
        ]
        if (i >= 3 ) {
            layer.msg('最多添加三句,内容可自行修改');
            return;
        }
        $("#dialog").append("<div id=\"add"+i+"\" style=\"margin-top: 4px;\">\n" +
            "                                <input type=\"text\" name=\"duihua_arr[]\" style=\"width:560px;\" lay-verify=\"required\" value='"+suggest[i+1]+"' placeholder=\"对话内容\" class=\"layui-input  layui-input-inline\">\n" +
            "                                <button type=\"button\" onclick=\"del('add"+i+"')\" class=\"layui-btn layui-btn-danger\">删除</button>\n" +
            "                            </div>");
    }
</script>
<{/block}>
